package analyzemytime.anlyzemytime;

import java.util.ArrayList;

import javax.swing.text.View;

public class CommandLine {
	public String period;
	public String view;
	public String period_year;
	public String period_month;
	public Boolean saveReport = false;
	public Boolean graph = false;
	private String firstName;
	private String lastName;
	private String projectName;
	private String type;
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public CommandLine(String[] args ){
		for(String param : args){
			String[] array = param.split("=");
			
	        System.out.println("param " + array[0]);
	        System.out.println("value " + array[1]);
	        
			if(array[0].equals("period")) {
				this.period = array[1];
				String[] period = array[1].split("-");
				this.period_year = period[0];
				this.period_month = period[1];
			}
			if(array[0].equals("view")) {
				this.view = array[1];
			}
			if(array[0].equals("save_report")) {
				this.saveReport = true;
			}
			if(array[0].equals("graph")) {
				this.graph = true;
			}
			if(array[0].equals("employee")){
				ArrayList<String> employee = new ArrayList<String>();
				for(String temp : array[1].split("_")){
					employee.add(temp);
				}
				if(employee.size()==2){
					this.setFirstName(employee.get(1));
					this.setLastName(employee.get(0));
				}else{
					System.out.println("Please provide employee first and last name as follows: SURNAME_NAME");
				}
			}else if(array[0].equals("project")){
					this.setProjectName(array[1]);
			}else if(array[0].equals("type")){
				this.setType(array[1]);
			}
		}
	}

	public String getPeriod_year() {
		return period_year;
	}

	public void setPeriod_year(String period_year) {
		this.period_year = period_year;
	}

	public String getPeriod_month() {
		return period_month;
	}

	public void setPeriod_month(String period_month) {
		this.period_month = period_month;
	}
}
